const BlogModel = require('../../models/BlogModel')

const BlogService = {
  getList: async ({ _id }) => {
    return _id ? BlogModel.find({ _id, isPublish: 1 }) : BlogModel.find({ isPublish: 1 }).sort({ updateTime: -1 })
  },
  getTopList: async ({ limit }) => {
    return BlogModel.find({ isPublish: 1 }).sort({ updateTime: -1 }).limit(limit)
  }
}

module.exports = BlogService